package com.hxzy.springbootrabbitmqproducer.controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 类说明
 *
 * @author admin
 * @date 2021-07-22
 */
@RestController
public class DirectExchangeController {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @GetMapping("/send/email")
    public String sendOrder(){
        String id= UUID.randomUUID().toString();
        System.out.println("下了订单，编号是："+id);

        //订阅发布模型 生产者
        this.amqpTemplate.convertAndSend("shop.direct","email",id);

        return id;
    }

    @GetMapping("/send/mobile")
    public String sendMobile(){
        String id= UUID.randomUUID().toString();
        System.out.println("下了订单，编号是："+id);

        //订阅发布模型 生产者
        this.amqpTemplate.convertAndSend("shop.direct","mobile",id);

        return id;
    }

}
